#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

int main(int argc, char const *argv[])
{
	printf("当前进程的pid=%d\n", getpid()); // 6572
	printf("当前进程的父进程pid=%d\n", getppid()); // 2489
	sleep(1);

	pid_t son = fork();
	if(son > 0) // 父进程
	{
		printf("我是你爸爸\n");
		printf("son=%d\n", son); // 6573
		printf("爸爸的pid=%d\n", getpid()); // 6572
		printf("爸爸的爸爸的pid=%d\n", getppid()); // 2489
		sleep(1);
	}
	else if (son == 0)
	{
		printf("我是子进程\n");
		printf("当前的pid=%d\n", getpid()); // 6573
		printf("当前的父进程pid=%d\n", getppid()); // 6572
		return 0;
	}
	
	return 0;
}
